package com.spring.boot.controller;

import com.spring.boot.entity.InsurancePolicy;
import com.spring.boot.service.InsurancePolicyService;
import com.spring.boot.vo.ContractParametersVO;
import com.spring.boot.vo.FindInsurancePolicyListVO;
import com.spring.boot.vo.FindVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.Map;

/**
 * @Author: ZTQ
 * @Date: 2021/01/01 17:26
 * @Description: TODO 保单管理 控制器
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/insurancePolicy")
public class InsurancePolicyController {
    @Autowired
    private InsurancePolicyService insurancePolicyService;

    /**
     * @param findInsurancePolicyListVO 自定义
     * @description: 查询保单列表（普通用户/管理员/财务人员）（管理员&财务人员 可以查询所有保单信息  普通用户只能查询自己合同  包含筛选查询）
     */
    @PostMapping(value = "/findInsurancePolicyListByUid", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map<String, Object> findInsurancePolicyListByUid(@RequestBody FindInsurancePolicyListVO findInsurancePolicyListVO) {
        //调用保单service层的findInsurancePolicyListByUid方法，进行查询保单信息操作
        Map<String, Object> insurancePolicy = insurancePolicyService.findInsurancePolicyListByUid(findInsurancePolicyListVO);
        //返回数据信息
        return insurancePolicy;
    }

    /**
     * @param insurancePolicyUuid 保单uuid
     * @description: 发起理赔
     */
    @GetMapping(value = "/updateInsurancePolicyByUuid", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map<String, Object> updateInsurancePolicyByUuid(@RequestParam  String insurancePolicyUuid) {
        //调用合同service层的updateInsurancePolicyByUuid方法，修改保单状态，发起理赔
        Map<String, Object> map = insurancePolicyService.updateInsurancePolicyByUuid(insurancePolicyUuid);
        //返回数据信息
        return map;
    }

    /**
     * @param insurancePolicyUuid 保单uuid
     * @description: 财务进行理赔
     */
    @GetMapping(value = "/settlementOfClaims", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map<String, Object> settlementOfClaims(@RequestParam  String insurancePolicyUuid,String money) {
        //调用合同service层的settlementOfClaims方法，进行理赔
        Map<String, Object> map = insurancePolicyService.settlementOfClaims(insurancePolicyUuid,money);
        //返回数据信息
        return map;
    }

    /**
     * @param findVo 查询对象
     * @description: 综合查询
     */
    @PostMapping(value = "/getComprehensiveInquiry", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map<String, Object> getComprehensiveInquiry(@RequestBody FindVo findVo) {
        //调用保单service层的getComprehensiveInquiry方法，进行新增险种操作
        Map<String, Object> comprehensiveInquiry = insurancePolicyService.getComprehensiveInquiry(findVo);
        //返回数据信息
        return comprehensiveInquiry;
    }
}
